<template>
  <div id="main">
    <div class="top-box">
      <img class="left-arrow" src="@/assets/书城/shape_u112.png" alt />
    </div>
    <div id="midbox" class="clear">
      <div class="userhead">
        <img :src="usereadinfo.headimg" alt />
      </div>
      <p class="username">{{usereadinfo.username}}</p>
      <p class="usertext">{{usereadinfo.usertext}}</p>
      <div class="usereadinfo">
        <div>
          <p class="usernum">{{usereadinfo.readtime}}</p>
          <p class="infokind">阅读时长</p>
        </div>
        <div>
          <p class="usernum">{{usereadinfo.viewnum}}</p>
          <p class="infokind">关注</p>
        </div>
        <div>
          <p class="usernum">{{usereadinfo.fans}}</p>
          <p class="infokind">粉丝</p>
        </div>
      </div>
      <div class="userbtn">
        <div class="addfriend" :class="{added:isadd}" @touchstart="addfriend">{{isaddfriend}}</div>
        <div class="talk" @touchstart="gotalking">聊天</div>
      </div>
    </div>
    <hr class="midline" />
    <p class="like">最近阅读</p>
    <div class="rebox">
      <ul>
        <li v-for="(value,key,index) in bookslist" :key="index">
          <div>
            <img :src="value.booksimg" alt />
          </div>
          <p>{{value.name}}</p>
        </li>
        <div class="lot">查看更多</div>
      </ul>
    </div>
    <hr class="midline" />
    <div class="bottombox">
      <p class="trends">动态（{{allnum}}）</p>
      <ul>
        <li v-for="(value,key,index) in usercommends" :key="index">
          <div class="top">
            <img :src="value.userimg" alt />
            <div>
              <p class="name">{{value.username}}</p>
              <p class="commendtime">{{value.time}}</p>
            </div>
          </div>
          <div class="commendtext">{{value.commend}}</div>
          <div class="rebook">
            <img :src="value.book.img" alt />
            <div class="bookinfo">
              <p class="bookname">{{value.book.name}}</p>
              <div class="bookscore">
                <div class="yellowstarnum">
                  <img v-for="(item,index) in value.book.star" :key="index" :src="yellowstar" alt />
                  <img src="@/assets/书城/路径_u3563.png" alt />
                  <img src="@/assets/书城/路径_u3563.png" alt />
                  <img src="@/assets/书城/路径_u3563.png" alt />
                  <img src="@/assets/书城/路径_u3563.png" alt />
                  <img src="@/assets/书城/路径_u3563.png" alt />
                </div>
                <div class="scorenum">{{value.book.score.toFixed(1)}}分</div>
              </div>
              <p class="author">{{value.book.author}}&nbsp;|&nbsp;{{value.book.kind}}</p>
            </div>
          </div>
          <div class="good">
            <div class="goodbtn" @touchstart="addgood">
              <div class="goodsimg" :class="{redgoodsimg:isred}"></div>
              <span>{{value.goodnum}}</span>
              <div class="addgoodbtn" v-if="isshow">
                <p>
                  <button @touchstart="changered">已登录</button>
                </p>
                <p>
                  <button @touchstart="gologin">未登录</button>
                </p>
              </div>
            </div>
            <div class="talkbtn">
              <img src="@/assets/书城/u2494.png" alt />
              <span>{{value.talk}}</span>
            </div>
            <div class="shapebtn"  @touchstart="gomask">
              <div class="shapeimg">
                <img src="@/assets/书城/路径_u3573.png" alt />
              </div>
              <span>{{value.shape}}</span>
            </div>
          </div>
          <hr class="reline" />
        </li>
        <div class="bottom">
          <div>
            <hr />
            <span>我是有底线的</span>
            <hr />
          </div>
        </div>
      </ul>
    </div>
    <div class="hidbox" :class="{addhidboxclass:isaddmask}">
      <p class="shapetitle">立即分享给好友</p>
      <div class="linkbox">
        <div>
          <div class="linkimg wximg">
            <img src="@/assets/wechatweibo/u1394.png" alt />
          </div>
          <span>微信</span>
        </div>
        <div>
          <div class="linkimg wbimg">
            <img src="@/assets/wechatweibo/u1397.png" alt />
            <img src="@/assets/wechatweibo/u1398.png" alt />
            <img src alt />
          </div>
          <span>微博</span>
        </div>
        <div>
          <div class="linkimg lkimg">
            <img width="24" height="24" src="@/assets/wechatweibo/u1402.svg" alt />
          </div>
          <span>复制连接</span>
        </div>
        <div>
          <div class="linkimg spimg">
            <img src="@/assets/wechatweibo/u1404.png" alt />
          </div>
          <span>分享海报</span>
        </div>
      </div>
      <hr class="hidboxline" />
      <p class="delbtn" @touchend="isaddmask=false">取消</p>
    </div>
    <div class="mask" :class="{addmaskclass:isaddmask}"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      isaddshapebox:false,
      isaddmask:false,
      isred: false,
      isshow: false,
      isadd: false,
      yellowstar: require("@/assets/书城/路径_u3559.png"),
      usereadinfo: {
        headimg: require("@/assets/书城/u3516.png"),
        username: "西瓜",
        usertext: "好好学习，天天向上",
        readtime: "9时30分",
        viewnum: 298,
        fans: 438
      },
      isaddfriend: "关注",
      bookslist: {
        books1: {
          name: "夜莺与玫瑰",
          booksimg: require("@/assets/u218.png")
        },
        books2: {
          name: "电影的宿命",
          booksimg: require("@/assets/u217.png")
        },
        books3: {
          name: "夜莺与玫瑰",
          booksimg: require("@/assets/u216.png")
        },
        books4: {
          name: "赤壁之戟",
          booksimg: require("@/assets/u215.png")
        },
        books5: {
          name: "重返昨日世界",
          booksimg: require("@/assets/u214.png")
        },
        books6: {
          name: "烽火与流星",
          booksimg: require("@/assets/u213.png")
        }
      },
      usercommends: {
        usercommend1: {
          userimg: require("@/assets/书城/ellipse_24_u3566.png"),
          username: "西瓜",
          time: "2022-05-20 10:00",
          commend:
            "我们人类和书很相似，每个人都有自己的故事，但最初谁也不了解谁 ，总是等待着被别人发现",
          book: {
            img: require("@/assets/书城/rectangle_46_u3556.png"),
            name: "置身事内",
            author: "[日]吉竹伸介",
            kind: "漫画/治愈",
            star: [0, 1, 2, 3],
            score: 9.0
          },
          goodnum: 330,
          talk: 3,
          shape: 189
        },
        usercommend2: {
          userimg: require("@/assets/书城/ellipse_24_u3566.png"),
          username: "西瓜",
          time: "2022-05-20 10:00",
          commend:
            "我们人类和书很相似，每个人都有自己的故事，但最初谁也不了解谁 ，总是等待着被别人发现",
          book: {
            img: require("@/assets/书城/rectangle_46_u3556.png"),
            name: "置身事内",
            author: "[日]吉竹伸介",
            kind: "漫画/治愈",
            star: [0, 1, 2, 3],
            score: 9.0
          },
          goodnum: 330,
          talk: 3,
          shape: 189
        },
        usercommend3: {
          userimg: require("@/assets/书城/ellipse_24_u3566.png"),
          username: "西瓜",
          time: "2022-05-20 10:00",
          commend:
            "我们人类和书很相似，每个人都有自己的故事，但最初谁也不了解谁 ，总是等待着被别人发现",
          book: {
            img: require("@/assets/书城/rectangle_46_u3556.png"),
            name: "置身事内",
            author: "[日]吉竹伸介",
            kind: "漫画/治愈",
            star: [0, 1, 2, 3],
            score: 9.0
          },
          goodnum: 330,
          talk: 3,
          shape: 189
        }
      }
    };
  },
  computed: {
    allnum() {
      let count = 0;
      for (let i in this.usercommends) {
        count++;
      }
      return count;
    }
  },
  methods: {
    addfriend() {
      if (this.isadd == false) {
        this.isadd = true;
        this.isaddfriend = "已关注";
      } else {
        this.isadd = false;
        this.isaddfriend = "关注";
      }
    },
    gomask(){
      if(this.isaddmask==false){
        this.isaddmask=true
      }else{
        this.isaddmask=false
      }
    },
    addgood() {
      this.isshow = true;
    },
    changered() {
      this.isred = true;
    },
    gotalking() {
      this.$router.push({
        path:'talking'
      },()=>{})
    },
    gologin() {}
  }
};
</script>

<style lang="less" scoped>
.midline {
  margin-top: 3rem;
  border: .1rem solid #f2f2f2;
}
.reline {
  margin-top: 2rem;
  margin-bottom: 2rem;
  border: .1rem solid #f2f2f2;
}
.clear::after {
  content: "";
  display: block;
  clear: both;
}
#main {
  box-sizing: border-box;
  width: 100%;
  overflow: hidden;
  margin-top: 5.8rem;
  .mask {
    width: 100%;
    position: fixed;
    background-color: black;
    opacity: 0.5;
    min-height: 100%;
    top: 100%;
    left: 0;
    z-index: 98;
  }
  .addmaskclass{
    animation: addmask 0.5s linear forwards;
  }
  @keyframes addmask {
    0%{
      top:100%;
    }
    100%{
      top: 0;
    }
  }
  .top-box {
    position: fixed;
    top: 0;
    left: 0;
    box-sizing: border-box;
    margin-bottom: 3.5rem;
    width: 100%;
    height: 1.6rem;
    display: flex;
    justify-content: space-between;
    background-color: rgba(255, 255, 255, 1);
    padding: 0 1.5rem;
    padding-top: 4.5rem;
    padding-bottom: 2.5rem;
    height: 5rem;
    z-index: 97;
    .left-arrow {
      width: .9rem;
      height: 1.4rem;
    }
  }
  #midbox {
    width: 100%;
    box-sizing: border-box;
    .userhead {
      width: 13.4rem;
      height: 13.4rem;
      margin: 0 auto;
      margin-top: 2.5rem;
      text-align: center;
    }
    .username {
      text-align: center;
      font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC";
      font-weight: 650;
      font-style: normal;
      font-size: 1.8rem;
      color: #11243d;
      height: 2.5rem;
      line-height: 2.5rem;
    }
    .usertext {
      margin-top: .5rem;
      font-family: "PingFangSC-Regular", "PingFang SC";
      font-weight: 400;
      font-style: normal;
      font-size: 1.4rem;
      color: #707a89;
      height: 2rem;
      line-height: 2rem;
      text-align: center;
    }
    .usereadinfo {
      margin-top: 2rem;
      display: flex;
      justify-content: space-around;
      .usernum {
        font-family: "PingFangSC-Medium", "PingFang SC Medium", "PingFang SC";
        font-weight: 500;
        font-style: normal;
        font-size: 1.6rem;
        color: #11243d;
        text-align: left;
      }
      .infokind {
        font-family: "PingFangSC-Regular", "PingFang SC";
        font-weight: 400;
        font-style: normal;
        font-size: 1.2rem;
        color: #707a89;
        text-align: left;
      }
    }
    .userbtn {
      width: 28.5rem;
      margin: 0 auto;
      display: flex;
      justify-content: space-between;
      margin-top: 2rem;
      .addfriend {
        width: 13rem;
        height: 4rem;
        background: inherit;
        background-color: rgba(65, 200, 114, 1);
        border: none;
        border-radius: .8rem;
        text-align: center;
        line-height: 4rem;
        font-family: "PingFangSC-Regular", "PingFang SC";
        font-weight: 400;
        font-style: normal;
        font-size: 1.4rem;
        color: #ffffff;
      }
      .added {
        background-color: rgba(204, 204, 204, 1);
      }
      .talk {
        width: 13rem;
        height: 4rem;
        background: inherit;
        background-color: rgba(255, 255, 255, 1);
        border: none;
        border-radius: .8rem;
        border-width: .1rem;
        border-style: solid;
        border-color: rgba(230, 230, 235, 1);
        border-radius: .8rem;
        font-family: "PingFangSC-Regular", "PingFang SC";
        font-weight: 400;
        font-style: normal;
        font-size: 1.4rem;
        color: #11243d;
        text-align: center;
        line-height: 4rem;
      }
    }
  }
  .like {
    margin-top: 1.5rem;
    padding-left: 1.5rem;
    font-family: "PingFangSC-Medium", "PingFang SC Medium", "PingFang SC";
    font-weight: 500;
    font-style: normal;
    font-size: 1.8rem;
    text-align: left;
    line-height: 2.6rem;
    margin-bottom: 1rem;
  }
  .rebox {
    overflow: hidden;
    padding-right: 1.5rem;
    height: 15rem;
    ul {
      display: flex;
      box-sizing: border-box;
      list-style: none;
      overflow: auto;
      padding: 0rem 1.5rem;
      min-height: 16.4rem;
      width: 100%;
      li {
        margin-right: 1rem;
        p {
          font-family: "PingFangSC-Regular", "PingFang SC";
          font-weight: 400;
          font-style: normal;
          font-size: 1.3rem;
          text-align: center;
        }
      }
      .lot {
        box-sizing: border-box;
        width: 4.2rem;
        height: 11.6rem;
        font-family: "PingFangSC-Regular", "PingFang SC";
        font-weight: 400;
        font-style: normal;
        font-size: 1.2rem;
        color: #999999;
        float: left;
        writing-mode: vertical-rl;
        text-align: center;
        padding-right: 1.2rem;
        padding-left: 1.2rem;
        background-color: #f2f2f2;
        border-radius: .9rem;
        letter-spacing: .5rem;
      }
    }
  }
  .bottombox {
    width: 100%;
    box-sizing: border-box;
    padding: 0 1.5rem;
    .trends {
      margin-bottom: 2rem;
      margin-top: 2rem;
      font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC";
      font-weight: 650;
      font-style: normal;
      font-size: 1.6rem;
      color: #11243d;
      text-align: left;
      line-height: 2.2rem;
    }
    ul {
      list-style: none;
      .bottom {
        width: 100%;
        height: 2.5rem;
        font-size: 1.2rem;
        color: #cccccc;
        padding-top: 2rem;
        div {
          font-family: "SourceHanSansSC-Normal", "思源黑体 Normal", "思源黑体";
          font-weight: 400;
          font-style: normal;
          text-align: left;
          height: 1.65rem;
          line-height: 1.65rem;
          position: relative;
          span {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
          }
          hr:nth-of-type(1) {
            position: absolute;
            width: 10rem;
            top: 50%;
            left: 3rem;
            transform: translateY(-50%);
            border: .1rem solid #f2f2f2;
          }
          hr:nth-of-type(2) {
            position: absolute;
            width: 10rem;
            top: 50%;
            right: 3rem;
            transform: translateY(-50%);
            border: .1rem solid #f2f2f2;
          }
        }
      }
      li {
        .top {
          display: flex;
          div {
            margin-left: 1rem;
            .name {
              font-family: "PingFangSC-Semibold", "PingFang SC Semibold",
                "PingFang SC";
              font-weight: 650;
              font-style: normal;
              font-size: 1.6rem;
              text-align: left;
            }
            .commendtime {
              font-family: "PingFangSC-Medium", "PingFang SC Medium",
                "PingFang SC";
              font-weight: 500;
              font-style: normal;
              font-size: 1.2rem;
              color: #999999;
              text-align: left;
            }
          }
        }
        .commendtext {
          font-family: "PingFangSC-Regular", "PingFang SC";
          font-weight: 400;
          font-style: normal;
          font-size: 1.5rem;
          color: #666666;
          text-align: left;
          margin-top: 1.5rem;
          margin-bottom: 1.5rem;
        }
        .rebook {
          box-sizing: border-box;
          display: flex;
          width: 34.3rem;
          height: 9.4rem;
          background: inherit;
          background-color: rgba(249, 249, 249, 1);
          border: none;
          border-radius: .8rem;
          padding: 1rem 1.5rem;

          .yellowstarnum {
            width: 6.5rem;
            height: 2rem;
            overflow: hidden;
          }
          .bookscore {
            display: flex;
            .scorenum {
              margin-left: 1rem;
              font-family: "PingFangSC-Medium", "PingFang SC Medium",
                "PingFang SC";
              font-weight: 500;
              font-style: normal;
              font-size: 1.2rem;
              color: #999999;
              text-align: left;
              line-height: 2rem;
              height: 2rem;
            }
          }
          .bookinfo {
            margin-left: 1.5rem;
            .bookname {
              font-family: "PingFangSC-Semibold", "PingFang SC Semibold",
                "PingFang SC";
              font-weight: 650;
              font-style: normal;
              font-size: 1.6rem;
              text-align: left;
              margin-bottom: .5rem;
            }
            .author {
              font-family: "PingFangSC-Medium", "PingFang SC Medium",
                "PingFang SC";
              font-weight: 500;
              font-style: normal;
              font-size: 1.2rem;
              color: #666666;
              text-align: left;
            }
          }
        }
        .good {
          width: 100%;
          display: flex;
          justify-content: space-between;
          font-size: 1.2rem;
          color: #999999;
          text-align: center;
          margin-top: 2rem;
          margin-bottom: 0;
          .goodbtn {
            display: flex;
            .goodsimg {
              width: 1.8rem;
              height: 1.8rem;
              background: url("@/assets/书城/u2490.png") no-repeat;
            }
            .redgoodsimg {
              background: url("@/assets/书城/u2491.png") no-repeat;
            }
            .addgoodbtn {
              position: fixed;
              left: 6.2rem;
              top: 39rem;
              font-family: arial;
              font-size: 1.2rem;
              text-align: left;
              border: .1rem solid #aaa;
              background: #fff none repeat scroll 0% 0%;
              border-radius: .3rem;
              white-space: nowrap;
              padding: .5rem .8rem;
              p {
                &:nth-of-type(1) {
                  margin-bottom: .2rem;
                }
              }
            }
          }
          .goodbtn,
          .talkbtn {
            img {
              vertical-align: middle;
            }
          }
          span {
            margin-left: .5rem;
          }
          .shapebtn {
            display: flex;
            .shapeimg {
              width: 1.8rem;
              height: 1.8rem;
              background: url("@/assets/书城/路径_u3572.png") no-repeat;
              position: relative;
              img {
                position: absolute;
                right: 0;
                top: 0;
              }
            }
          }
        }
      }
    }
  }
  .hidbox {
    position: fixed;
    bottom: -100%;
    left: 0;
    z-index: 99;
    box-sizing: border-box;
    width: 100%;
    height: 20.4rem;
    background: inherit;
    background-color: rgba(255, 255, 255, 1);
    border-width: .1rem;
    border-style: solid;
    border-color: rgba(255, 255, 255, 1);
    border-radius: 2rem;
    border-bottom-left-radius:0 ;
    border-bottom-right-radius:0 ;
    
    .shapetitle {
      font-family: "ArialMT", "Arial";
      font-weight: 400;
      font-style: normal;
      font-size: 1.4rem;
      text-align: center;
      margin-top: 2rem;
      margin-bottom: 2rem;
    }
    .hidboxline {
      margin-top: .8rem;
      margin-bottom: .8rem;
      border: .5rem solid #f2f2f2;
    }
    .delbtn {
      text-align: center;
      font-size: 1.4rem;
      color: #323233;
      font-weight: 400;
    }
    .touchdelbtn{
      background-color: #f2f2f2; 
    }
    .linkbox {
      display: flex;
      justify-content: space-evenly;
      div {
        display: flex;
        flex-direction: column;
        align-items: center;
        span {
          font-family: "ArialMT", "Arial";
          font-weight: 400;
          color: #333333;
          font-size: 1.2rem;
        }
        .linkimg {
          margin-bottom: .5rem;
          width: 5rem;
          height: 5rem;
          border-radius: 50%;
        }
        .wximg {
          background: url("@/assets/wechatweibo/u1393.png");
          position: relative;
          img {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
          }
        }
        .wbimg {
          background: url("@/assets/wechatweibo/u1399.png");
          position: relative;
          img {
            position: absolute;
            left: 46%;
            top: 58%;
            transform: translate(-50%, -50%);
            &:last-of-type {
              position: absolute;
              left: 50%;
              top: 50%;
              transform: translate(-50%, -50%);
            }
          }
        }
        .lkimg {
          background: url("@/assets/wechatweibo/u1401.png");
          position: relative;
          img {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
          }
        }
        .spimg {
          background: url("@/assets/wechatweibo/u1401.png");
          position: relative;
          img {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
          }
        }
      }
    }
  }
  .addhidboxclass{
      animation: addhidbox 0.5s linear forwards;
    }
    @keyframes addhidbox {
      0%{
        bottom: -100%;
      }
      100%{
        bottom: 0;
      }
    }
}
</style>